package com.jk.dmconsumer.djhController;

import com.jk.dmcommon.djhEntity.DjhDistrEntity;
import com.jk.dmcommon.djhEntity.DjhWatchPersonEntity;
import com.jk.dmconsumer.djhService.DjhPayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("payOrderDjh")
public class DjhPayOrderController {
    @Autowired
    private DjhPayOrderService djhPayOrderService;

    @RequestMapping("addPersonForm")
    public void addPersonForm(DjhWatchPersonEntity djhWatchPersonEntity){
                djhPayOrderService.addPersonForm(djhWatchPersonEntity);
    }

    /**
     * peisong
     */
    @RequestMapping("selectPeisong")
    public List<DjhDistrEntity> selectPeisong(Integer userId){
        return djhPayOrderService.selectPeisong(userId);
    }
    //观影人回显
    @RequestMapping("selectAllWatchPerson")
    public String selectAllWatchPerson(){
        List<DjhWatchPersonEntity> djhWatchPersonEntities = djhPayOrderService.selectAllWatchPerson();
        String str = "";
        for (DjhWatchPersonEntity d: djhWatchPersonEntities
             ) {
           /* str += "<input type=\"radio\" name = \"watchPerson\" value=\""+d.getPersonId()+"\" />"+
                    "<div  style=\"display: inline-block;padding: 5px;line-height: 3px;\"> 观影人："+d.getPersonName()+"<br />" +
                    "观影人证件号："+d.getPapersNumber().replace(d.getPapersNumber().substring(5,9),"****")+"<br />" +
                    " </div>";*/
                String number = d.getPapersNumber().replace(d.getPapersNumber().substring(5,9),"****");
            str+="<div class=\"ticket-buyer-detail-item\">\n" +
                    "            <div class=\"ticket-buyer-detail-title\">\n" +
                    "                观演人\n" +
                    "            </div>\n" +
                    "            <div class=\"ticket-buyer-detail-content\">\n" +
                    "                <span>观演人姓名：</span>"+d.getPersonName()+"\n" +
                    "            </div>\n" +
                    "            <div class=\"ticket-buyer-detail-content\">\n" +
                    "                <span>证件类型：</span>"+d.getPapersType()+"\n" +
                    "            </div>\n" +
                    "            <div class=\"ticket-buyer-detail-content\">\n" +
                    "                <span>证件号码：</span>"+number+"\n" +
                    "            </div>\n" +
                    "        </div>";
            break;
        }
        return str;
    }
    //观影人2
    @RequestMapping("selectAllWatchPerson2")
    public DjhWatchPersonEntity selectAllWatchPerson2() {
        List<DjhWatchPersonEntity> djhWatchPersonEntities = djhPayOrderService.selectAllWatchPerson();
        DjhWatchPersonEntity djhWatchPersonEntity = new DjhWatchPersonEntity();
        for (DjhWatchPersonEntity person: djhWatchPersonEntities) {
            djhWatchPersonEntity = person;
            break;
        }
        return djhWatchPersonEntity;
    }
}
